package net.zcscloud.zhuohcun.zeco.controller;

import net.zcscloud.zhuohcun.zeco.common.controller.LogicController;
import net.zcscloud.zhuohcun.zeco.dao.VideotokenDao;
import net.zcscloud.zhuohcun.zeco.entity.Usertoken;
import net.zcscloud.zhuohcun.zeco.entity.Videotoken;
import net.zcscloud.zhuohcun.zeco.service.UserService;
import net.zcscloud.zhuohcun.zeco.service.VideotokenService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Api(tags = "视频令牌的控制器")
@RestController
@RequestMapping("/api/videotoken")
@CrossOrigin(origins = "*")
public class VideotokenController extends LogicController<VideotokenService, VideotokenDao,Videotoken,Long> {
    public VideotokenController(@Autowired VideotokenService service){
        super(service);
    }
    @Autowired
    private VideotokenService videotokenservice;
    @Autowired
    private UserService userService;
    @PostMapping("/gettoken")
    public String getAccesstoken(@RequestBody Usertoken usertoken) throws IOException {
        if(userService.verifyToken(usertoken.getToken())=="0"){
            return videotokenservice.updateToken();
        }
        return null;
    }
}
